﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Xml.Serialization;
using Landpy.CruiseControlNet.Infrastructure.Control;

namespace Landpy.CruiseControlNet.FacadeInterface.ConfigurationModule
{
    public class Security
    {
        [Category("Basic")]
        [Description("The type of internal sercurity.")]
        [XmlAttribute("type")]
        public SecurityType Type { get; set; }

        [Category("Basic")]
        [Description("The default right to use.")]
        [XmlAttribute("defaultRight")]
        public PermissionCategoryType DefaultRight { get; set; }

        [Editor(typeof(MultipleTypeCollectionEditor), typeof(UITypeEditor))]
        [Category("Basic")]
        [Description("The permissions of internal sercurity.")]
        [XmlArray("permissions")]
        [XmlArrayItem("rolePermission", Type = typeof(RolePermission))]
        [XmlArrayItem("userPermission", Type = typeof(UserPermission))]
        public List<Permission> Permissions { get; set; }

        public Security()
        {
            this.Permissions = new List<Permission>();
            this.DefaultRight = PermissionCategoryType.Deny;
        }
    }
}
